package com.ruoyi.ftrl.mqtt.handler;

import com.ruoyi.ftrl.mqtt.service.MqttService;
import com.ruoyi.ftrl.mqtt.service.impl.MqttServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 设备数据处理器
 */
@Component
public class DeviceDataHandler {
//    @Autowired
//    MqttService mqttService;
@Autowired
private MqttServiceImpl mqttService1;
    
    private static final Logger log = LoggerFactory.getLogger(DeviceDataHandler.class);
    
    /**
     * 处理设备数据
     * 
     * @param payload 消息内容
     */
    public void handleDeviceData(String payload) {
        // TODO: 根据业务需求实现数据处理和存储逻辑
        log.info("处理设备数据: {}", payload);

//         示例：将数据发布到MQTT
         mqttService1.publishMessage("device/data", payload);

        // 例如：解析JSON数据
        // JSONObject jsonData = JSON.parseObject(payload);
        
        // 数据存储
        // deviceDataService.saveDeviceData(jsonData);
    }
}